package com.nbsaas.boot.shopArticle.rest.convert;

import com.nbsaas.boot.shopArticle.data.entity.ShopArticleCatalog;
import com.nbsaas.boot.shopArticle.api.domain.response.ShopArticleCatalogResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* 资讯分类-实体对象转化成响应对象
*/

public class ShopArticleCatalogResponseConvert  implements Converter<ShopArticleCatalogResponse,ShopArticleCatalog> {

    @Override
    public ShopArticleCatalogResponse convert(ShopArticleCatalog source) {
        ShopArticleCatalogResponse  result = new  ShopArticleCatalogResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getParent()!=null){
                        result.setParent(source.getParent().getId());
                    }
                    if(source.getShop()!=null){
                        result.setShop(source.getShop().getId());
                    }

                    try {
                        if(source.getShop()!=null){
                            result.setShopName(source.getShop().getName());
                        }
                    } catch (Exception ignored) { }

        return result;
    }

}

